import os


class Config:
    # 基础配置
    SECRET_KEY = 'my-secret-key'
    DEBUG = False
    DATABASE_URI = 'sqlite:///mydatabase.db'
    LOG_LEVEL = 'INFO'


class DevelopmentConfig(Config):
    # 开发环境配置
    DEBUG = True
    DATABASE_URI = 'sqlite:///dev_mydatabase.db'


class TestingConfig(Config):
    # 测试环境配置
    TESTING = True
    DATABASE_URI = 'sqlite:///test_mydatabase.db'


class ProductionConfig(Config):
    # 生产环境配置
    DATABASE_URI = 'postgresql://user:password@localhost/mydatabase'


# 根据环境变量选择配置
config_name = os.getenv('FLASK_ENV') or 'development'
if config_name == 'development':
    app_config = DevelopmentConfig
elif config_name == 'testing':
    app_config = TestingConfig
elif config_name == 'production':
    app_config = ProductionConfig
else:
    raise ValueError('Invalid FLASK_ENV environment variable')